home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / vector / Vector.c < prev    next >
C/C++ Source or Header  |  1990-05-16  |  3KB  |  111 lines

  1. /* Vector.c -- abstract base class for vectors
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet: kgorlen@alw.nih.gov
  20.     February, 1987
  21.  
  22. Function:
  23.     
  24. Modification History:
  25.  
  26. $Log:    Vector.c,v $
  27.  * Revision 3.0  90/05/16  23:00:44  kgorlen
  28.  * Release for 1st edition.
  29.  * 
  30. */
  31.  
  32. #include "Vector.h"
  33. #include "nihclIO.h"
  34.  
  35. #define    THIS    Vector
  36. #define    BASE    Object
  37. #define BASE_CLASSES BASE::desc()
  38. #define MEMBER_CLASSES
  39. #define VIRTUAL_BASE_CLASSES
  40.  
  41. DEFINE_ABSTRACT_CLASS(Vector,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/vector/RCS/Vector.c,v 3.0 90/05/16 23:00:44 kgorlen Rel $",NULL,NULL);
  42.  
  43. extern const int NIHCL_RDABSTCLASS;
  44. extern const int NIHCL_VECTOREMPTY;
  45. extern const int NIHCL_VECTORLENGTH;
  46.  
  47. unsigned Vector::capacity() const   { return n; }
  48.  
  49. unsigned Vector::size()    const        { return n; }
  50.  
  51. void Vector::free() {}    // used by Slice classes to free TempVecs
  52.  
  53. void Vector::emptyErr(const char* fname) const
  54. {
  55.     setError(NIHCL_VECTOREMPTY,DEFAULT,className(),fname,(int)this);
  56. }
  57.  
  58. void lengthErr(const Vector& U, const Vector& V)
  59. {
  60.     NIHCL::setError(NIHCL_VECTORLENGTH,DEFAULT,(int)&U,U.className(),U.length(),(int)&V,V.className(),V.length());
  61. }
  62.  
  63. void Vector::deepenShallowCopy()
  64. // Called by deepCopy() to convert a shallow copy to a deep copy.
  65. {
  66. }
  67.  
  68. #ifndef BUG_bC2728
  69. // call of pure virtual function OIOin::operator >>() in constructor Vector::Vector()
  70. static unsigned hack(OIOin& strm)    { unsigned n; strm >> n; return n; }
  71. #endif
  72.  
  73. Vector::Vector(OIOin& strm)
  74. // Construct an object from istream "strm" at address "where".
  75.     : BASE(strm)
  76. {
  77. #ifndef BUG_bC2728
  78.     n = hack(strm);
  79. #else
  80. // call of pure virtual function OIOin::operator >>() in constructor Vector::Vector()
  81.     strm >> n;
  82. #endif
  83. }
  84.  
  85. void Vector::storer(OIOout& strm) const
  86. // Store the member variables of this object on ostream "strm".
  87. {
  88.     BASE::storer(strm);
  89.     strm << n;
  90. }
  91.  
  92. Vector::Vector(OIOifd& fd)
  93. // Construct an object from file descriptor "fd" at address "where".
  94.     : BASE(fd)
  95. {
  96.     fd >> n;
  97. }
  98.  
  99. void Vector::storer(OIOofd& fd) const
  100. // Store an object on file descriptor "fd".
  101. {
  102.     BASE::storer(fd);
  103.     fd << n;
  104. }
  105.  
  106. int Vector::compare(const Object&) const
  107. {
  108.     shouldNotImplement("compare");
  109.     return 0;
  110. }
  111.